package net.jumpengine.event;

import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import net.jumpengine.M;
import net.jumpengine.Manager;
import net.jumpengine.bean.ImageBase;
import net.jumpengine.bean.TableBase;
import net.jumpengine.bean.TextBase;
import net.jumpengine.init.TableBaseInit;
import net.jumpengine.inter.IStateEvent;
import net.jumpengine.util.UComm;

public class RunningStateEvent implements IStateEvent {
	private boolean load=false;
	private ImageBase back;
	
	@Override
	public void setBackImage(Image image) {
		if(back==null) {
			back=new ImageBase(0, 0, image);
			M.i().add(back);
		}else {
			back.setImage(image);
		}
	}

	@Override
	public boolean isLoaded() {
		return load;
	}

	@Override
	public void load() {
		Manager.getLog().debug("RunningStateEvent[load]");
		
		int width= Manager.getWidth();
		int left=60,top=50;
		Manager.setFont(new Font("幼圆",top));
		TextBase text;
		for(int i=-left;i<width;i+=left) {
			text=new TextBase(i, i/left*top, "Hello World!");
			text.setColor(Color.rgb(UComm.rnd(100, 255), UComm.rnd(100, 255), UComm.rnd(100, 255)));
			Manager.getImageManager().add(text);
		}
		
		TableBase<?> tableBase = TableBaseInit.init(50, 10, 530, 736);
		tableBase.setIndex(1);
		M.i().add(tableBase);
		
		load=true;
	}
	
	@Override
	public void show() {
	}

	@Override
	public void pause() {
		
	}

	@Override
	public void end() {
		
	}


}
